
package com.oahcfly.chgame.core.ui;

import java.util.HashMap;

import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.Group;

/** 绘制层
 * 
 * @author haocao */
public abstract class CHLayer extends Group {

	// 层id
	private int layerId;

	private HashMap<String, Actor> actorsMap = new HashMap<String, Actor>();

	/** 层位置，越大绘制越在上面
	 * 
	 * @param id */
	public CHLayer (int id) {
		this.layerId = id;
	}

	public void setLayerId (int id) {
		this.layerId = id;
	}

	public int getLayerId () {
		return layerId;
	}

	public HashMap<String, Actor> getActorsMap () {
		return actorsMap;
	}

	@Override
	public void addActor (Actor actor) {
		// TODO Auto-generated method stub
		super.addActor(actor);
		actorsMap.put(actor.getName(), actor);
	}

	@Override
	public boolean removeActor (Actor actor) {
		// TODO Auto-generated method stub
		boolean ok = super.removeActor(actor);
		if (ok) actorsMap.remove(actor.getName());
		return ok;
	}

}
